from library.api.db import EntityModel, db


class CiProject(EntityModel):
    ACTIVE = 0
    DISABLE = 1

    name = db.Column(db.String(128))  # project name
    git_url = db.Column(db.String(256))  # git url
    git_project_id = db.Column(db.Integer)  # gitlab idt
    git_hook_url = db.Column(db.String(256))  # jenkins job url
    git_hook_token = db.Column(db.String(128))  # jenkins job token
    project_type = db.Column(db.Integer)  # 服务类型 1-java 2-python 3-node 4-app
    deploy_module_name = db.Column(db.String(128))
    exclusions = db.Column(db.String(512))  # 排除文件
    dingding = db.Column(db.String(128))  # dingding_token
    project_members = db.Column(db.String(512))  # 项目人员
    status = db.Column(db.Integer, default=ACTIVE)


class CiData(EntityModel):
    ACTIVE = 0
    DISABLE = 1

    ci_project_id = db.Column(db.Integer)  # 关联CiProject id
    name = db.Column(db.String(256))  # job name
    env = db.Column(db.String(20))  # 环境
    template_version = db.Column(db.Integer)  # 模版版本
    branch = db.Column(db.String(128))
    report_url = db.Column(db.String(256))
    accuracy = db.Column(db.String(10))  # 用例正确率
    case_count = db.Column(db.Integer)  # 用例个数
    nextBuildNumber = db.Column(db.Integer)  # 下一个执行number
    # is_executing = db.Column(db.Integer)  # 0 未执行,1正在执行
    task_id = db.Column(db.String(50))  # 关联flow id
    status = db.Column(db.Integer, default=ACTIVE)
    description = db.Column(db.String(512))  # job 的描述


class CiRecord(EntityModel):
    pass
